package controllers;

import models.*;

public class Security extends Secure.Security {

    static boolean authentify(String username, String password) {
        User user = User.connect(username, password);
        if (user != null) {
            session.put("login", user.email);
            return true;
        }
        return false;
    }
    
    static boolean check(String role) {
        if(User.find("byEmail", connected()).<User>first().role.equalsIgnoreCase(role)) {
            return true;
        }
        return false;
    }
    
    static void onDisconnected() {
        Application.index();
    }
    
    static void onAuthenticated() {
        Application.index();
    }
    
}

